<template>
	<view class="content">
		<u-loading-page :loading="pageLoading"></u-loading-page>
		<view v-if="!pageLoading">
			<u-swiper :list="banner" radius="0" height="200" keyName="image" showTitle :autoplay="false"
				circular @click="clickBanner"></u-swiper>
			<!-- <u-notice-bar :text="notice"  bgColor="#E3F2E6" color="#333" direction="column"></u-notice-bar> -->
			<u-gap height="15" bgColor="#f7f7f7"></u-gap>
			<view class="page-title">
				<view class="text">乡村快讯</view>
				<view class="icon" @click="navTo('/pages/village/news/index')">
					<u--text customClass="ml-auto" suffixIcon="arrow-rightward" iconStyle="font-size: 12px" color="#999" text="查看更多"></u--text>
				</view>
			</view>
			<view class="village-news">
				<view class="village-item" v-for="item in pageData.featureMap.village_news.highlights">{{item}}</view>
			</view>
			<u-gap height="15" bgColor="#f7f7f7"></u-gap>
			<view class="menu-box ">
				<view class="menu-item" v-for="item in pageData.features" :style="item.style" @click="navTo(item.target)">
					<view><text style="font-size: 24px;color:linen" :class="item.icon"></text></view>
					<view class="mt-20"></view>{{item.title}}
				</view>
				<!-- <view class="menu-item" @click="navTo('/pages/serviceLog/index')">
					服务日志
				</view>
				<view class="menu-item" @click="navTo('/pages/bmservice/post_cases')">
					平安建设-安全防护
				</view>
				<view class="menu-item" @click="navTo('/pages/bmservice/post_cases')">
					平安建设-和谐家园
				</view>
				<view class="menu-item" @click="navTo('/pages/bmservice/post_cases')">
					乡村文化特色
				</view>
				<view class="menu-item" @click="navTo('/pages/town/index')">
					驿旅拾光
				</view>			 -->
				<!-- <view class="menu-item">
				<image src="@/static/djyl.jpg"></image>
			</view> -->
				<!-- <view v-for="item in pageData.features" class="menu-item"  @click="navTo('/pages/bmservice/post_cases')">
				<image src="@/static/pajs.jpg"></image>
			</view> -->
				<!-- <view class="menu-item" @click="navTo('/pages/town/index')">
				<image src="@/static/xczx.jpg"></image>
			</view> -->
				<!-- <view class="menu-item" @click="navTo('/pages/bmservice/index')">
				<image src="@/static/bmfw.jpg"></image>
			</view>
			<view class="menu-item" @click="navTo('/pages/village/news/index')">
				乡村快讯
			</view> -->
				<!-- 	<view class="menu-item" @click="navTo('/pages/town/governance')">
				六员服务
			</view> -->
			</view>
			<u-gap height="15" bgColor="#f7f7f7"></u-gap>
			<view class="page-title">乡村文化特色</view>
			<view class="p-30">
				<video id="myVideo" :poster="pageData.culturalShowcase.coverImage" :src="pageData.culturalShowcase.mediaUrl" controls></video>
			</view>
		</view>
	</view>
</template>
<script>
	import {
		getHome
	} from '@/config/api';
	export default {
		data() {
			return {
				pageLoading: true,
				pageData: {},
				notice: [],
				banner: [],
			}
		},
		onLoad() {
			this.getPageData()
		},
		onPullDownRefresh() {
			this.getPageData(function(){
				uni.stopPullDownRefresh();
			})
		},
		methods: {
			getPageData(cb) {
				getHome().then(res => {
					this.pageData = res;
					this.banner = res.banner.map(item=>{
						return {image:item.imageUrl,title:item.text}
						});
					this.pageLoading = false;
					typeof cb =='function' && cb();
				})
			},
			clickBanner(index){
				this.navTo(this.pageData.banner[index].target);
			}
		}
	}
</script>

<style lang="scss">

	.menu-box {
		display: flex;
		align-items: center;
		flex-wrap: wrap;
		padding:15rpx;
		.menu-item {
			width: calc(50% - 30rpx);
			margin: 15rpx;
			background-color: lightblue;
			height: 184rpx;
			border-radius: 10rpx;
			overflow: hidden;
			text-align: center;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			image {
				width: 100%;
				height: 184rpx;
				border-radius: 10rpx;
				overflow: hidden;
			}
		}
	}
	.village-news{
		padding:10rpx 30rpx;
		.village-item{
			padding:16rpx 0;
			display: flex;
			align-items: center;
			font-size: 14px;
			&:before{
				content:"";
				display: block;
				width:8px;
				height:8px;
				border-radius: 8px;
				background-color: lightseagreen;
				margin-right:5px;
				
			}
		}
	}

	#myVideo{
		width: 100%;
		height:180px;
		border-radius: 10px;
	}
</style>